import { Component } from '@angular/core';
import { mysqlLogsService } from "../mysqlLogs.service";
import { NzMessageService } from "ng-zorro-antd";

@Component({
    selector: 'app-table-full',
    templateUrl: './full.component.html',
    styleUrls: []
})
export class TableFullComponent {

    pi = 1;
    ps = 10;
    total = 200; // mock total
    list = [];
    loading = false;
    args = {};

    load(pi?: number) {
        if (typeof pi !== 'undefined') this.pi = pi || 1;
        this.loading = true;

        this._sqlList.getLogs(this.pi, this.ps, this.args)
            .map(data => {
                return data;
            })
            .subscribe(data => {
                this.loading = false;
                this.list = data.List;
                this.total = data.Count;
            })
    }

    clear() {
        this.args = {};
        this.load(1);
    }

    constructor(private _sqlList: mysqlLogsService, private message: NzMessageService) {
    }

    ngOnInit() {
        this.load();
    }

    //showMsg(msg: string) {this.message.info(msg);}
}
